//
//  GGMainViewController.m
//  GGInternbird
//
//  Created by 耿文康 on 16/3/7.
//  Copyright © 2016年 耿文康. All rights reserved.
//

#import "GGMainViewController.h"
#import "GGNavViewcontroller.h"
#import "GGToolsMainVC.h"
#import "GGRecreationMainVC.h"
#import "GGWheelMainVC.h"

@implementation GGMainViewController
- (void)viewDidLoad{
    [super viewDidLoad];
    [self addChildViewControllers];
    // UITabBarItem文字颜色
    
    UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
    
    bgView.backgroundColor = HEXColor(0x000000, 1);
    [self.tabBar insertSubview:bgView atIndex:0];
    self.tabBar.opaque = YES;
    UIColor *color = HEXColor(0xffffff, 1);
    UIColor *colorSelect = HEXColor(0x0ad986, 1);
    [[UITabBarItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:color,NSFontAttributeName:[UIFont systemFontOfSize:10]} forState:UIControlStateNormal];
    [[UITabBarItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:colorSelect,NSFontAttributeName:[UIFont systemFontOfSize:10]} forState:UIControlStateSelected];
    
}

- (void)addChildViewControllers {
    GGToolsMainVC *toolsMainVC = [[GGToolsMainVC alloc] init];
    GGRecreationMainVC *recreationMainVC = [[GGRecreationMainVC alloc] init];
    GGWheelMainVC *wheelMainVC = [[GGWheelMainVC alloc] init];
//    GGStudyVC *studyVC = [[GGStudyVC alloc] init];
//    GGArticleVC *articleVC = [[GGArticleVC alloc] init];
//    GGMeVC *meVC = [[GGMeVC alloc] init];
    [self addchildVC:toolsMainVC title:@"工具" imageName:@"ToolsNor" backImageName:@"ToolsPress"];
    [self addchildVC:wheelMainVC title:@"轮子" imageName:@"WheelNor" backImageName:@"WheelPress"];
    [self addchildVC:recreationMainVC title:@"娱乐" imageName:@"recreationNor" backImageName:@"recreationPress"];
//    [self addchildVC:meVC title:@"我的" imageName:@"mineNor" backImageName:@"tabMinePress"];
}

- (void)addchildVC:(UIViewController *)viewVC title:(NSString *)title imageName:(NSString *)imageName  backImageName:(NSString *)backImageName {
    
    viewVC.title = title;
    viewVC.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    viewVC.tabBarItem.selectedImage = [[UIImage imageNamed:backImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    GGNavViewcontroller *navVC = [[GGNavViewcontroller alloc] initWithRootViewController:viewVC];
    [self addChildViewController:navVC];
}
@end
